import {changePremium, getSession} from "@/actions";
import {redirect} from "next/navigation";

export default async function ProfilePage() {
    const session = await getSession();
    if (!session.isLoggedIn) {
        redirect("/")
    }
    return (
        <div className="mt-4">
            <h1 className="text-2xl">Welcome to the ProfilePage</h1>
            <p>Welcome, <b>{session.username}</b></p>
            <span>You are a <b>{session.isPro ? "Premium" : "Free"}</b> User</span>
            <form action={changePremium}>
                <button className="bg-red-400 p-2">{session.isPro ? "Cancel" : "Buy"} Premium</button>
            </form>
        </div>
    )
}